<%@page import="java.util.Vector"%>
<%@page import="java.util.ArrayList"%>
<%@ include file="../includes/common.jsp"%>
<%@page import="application.RestoService"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.:: Reservation du restaurant &agrave; Connexion ::.</title>
<style type="text/css">
<!--
.Style2 {
	color: #333333
}

a:link {
	text-decoration: none;
	color: #000000;
}

a:visited {
	text-decoration: none;
}

a:hover {
	text-decoration: none;
}

a:active {
	text-decoration: none;
}

.Style3 {
	color: #FFFFFF;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}

.Style4 {
	color: #000000
}

.Style8 {
	color: #333333;
	font-size: 12px;
}

.Style11 {
	font-family: "Arial", Times, serif;
	color: #AD0432;
	font-size: 12px;
}
-->
</style>
<script type="text/JavaScript">
<!--
	function listCategory(category_list) {
		if (category_list.options[category_list.selectedIndex].value == '-1') {
			return;
		}
		category_list.form.elements['id_category'].value = category_list.options[category_list.selectedIndex].value;
	}
//-->
</script>
</head>

<body>
	<center>
		<form name="food_consultation" id="food_consultation"
			action="consultation.jsp" method="post">
			<table border="0" style="border: 1px:solid">
				<tr>
					<td width="1114" height=""><img src="../image/banner1.jpg"
						width="1000" /></td>
				</tr>

				<%
					id_category = request.getParameter("id_category");
					String user_id = (String) session.getAttribute("user_id");
					if (user_id != null) {
				%>

				<tr>
					<td>
						<div align="right">
							Bienvenue <b> <%
 	out.println(user_id);
 %></b>
						</div>
					</td>
				</tr>
				<%
					}
				%>

				<tr valign="top">
					<td height="178"><table width="1115" border="0">
							<tr bgcolor="#3399FF">
								<td width="672" height="21" class="Style3">Consultation</td>

								<td><input type="hidden" name="id_category" value=""
									id="id_category" /> <select onChange="listCategory(this);">
										<option value="-1">--- Select ---</option>
										<%
											ArrayList<ArrayList<String>> categories = new ArrayList<ArrayList<String>>();
											ArrayList<String> category = new ArrayList<String>();
											categories = new RestoService().listAllCategory();
											for (int i = 0; i < categories.size(); i++) {
												category = categories.get(i);
										%>
										<option value="<%=category.get(0)%>"><%=category.get(1)%></option>
										<%
											}
										%>
								</select>
								
								
								<input name="s" type="submit" class="button" value="Filtrer" />
								
								</td>


								<td bgcolor="#3399FF"><div align="right">
										<span class="Style2"><a href="index.jsp">Accueille</a>
											| <a href="reservation_view.jsp">Gestion des reservations
										</a> </span>
									</div></td>
							</tr>

							<%
								int icount = 0;
								ArrayList<ArrayList<String>> food_list = new ArrayList<ArrayList<String>>();
								ArrayList<String> food = new ArrayList<String>();
								RestoService resto = new RestoService();
								if(id_category == null || id_category.equalsIgnoreCase("-1") || id_category == "")
									food_list = resto.listAllFood();
								else
									food_list = resto.listFoodWithCategory(id_category);
								int size = food_list.size();
								while (icount < size) {
									food = food_list.get(icount);
									id_food = food.get(0);
									id_category = food.get(1);
									name_food = food.get(2);
									description_food = food.get(3);
									country_food = food.get(4);
									image_food = food.get(5);
									price = food.get(6);
									icount++;
							%>

							<tr>

								<td class="content_15"><a
									href="food_detail.jsp?id_food=<%=id_food%>&name_food=<%=name_food%>"><strong
										class="content_title"> <%
 	out.print(name_food);
 %>
									</strong></a>&nbsp;<img src="../image/hotnews.gif" border="0" /><br /> <img
									src=<%out.print(image_food);%> border="0" height="120"
									hspace="5" vspace="5" align="left" /> <%
 	out.print(description_food);
 %> &nbsp;... <a
									href="food_detail.jsp?id_food=<%=id_food%>&name_food=<%=name_food%>">Lire
										la suite</a><br /> <br /></td>
							</tr>
							<%
								}
							%>

						</table></td>
				</tr>
				<tr>
					<td bgcolor="#3399FF"><div align="right"></div></td>
				</tr>
				<tr>
					<td class="Style8">Projet con&ccedil;u dans le cadre du cours
						de Gestion de projet</td>
				</tr>
				<tr>
					<td class="Style8">Par : Nguyen Quoc Khai et Nguyen Huu Nguyen</td>
				</tr>
			</table>
		</form>
	</center>
</body>
</html>


